import React, { Component } from 'react'
import { NavBar, WhiteSpace, SearchBar } from "antd-mobile";
import "./components/css/home.less"
import GETnew from './components/getnew/getnew';
import Wanren from "./components/groupon/groupon"
import Seckill from './components/seckill/seckill';
import yhq from "../../assets/img/yhq.png"
import yhqlq from "../../assets/img/yhqlq.png"
import home_menu from "../../assets/img/home_menu.png"
import { actions, getNewlist, getseckilllist, getWanrenlist } from '../../store/modules/home';
import {bindActionCreators} from "redux"
import {connect} from "react-redux"

 class home extends Component {

    async componentDidMount() {
        let {home:{reqGetnewAction,reqWanrenAction,reqSeckillAction}}=this.props;
        reqGetnewAction()
        reqWanrenAction()
        reqSeckillAction()
    }
    render() {
        let { getnewlist, wanrenlist, seckilllist } = this.props
        return (
            <div>
                <NavBar>首页</NavBar>

                <SearchBar placeholder="搜索" maxLength={8} />
                <WhiteSpace />

                {getnewlist.length > 0 ? <GETnew getnewlist={getnewlist}></GETnew> : null}

                <div className="yhq">
                    <h3>二重礼</h3>
                    <img className="left" src={yhq} alt="" />
                    <img className="right" src={yhqlq} alt="" />
                </div>
                <div className="home_menu">
                    <img src={home_menu} alt="" />
                </div>

                {wanrenlist.length > 0 ? <Wanren wanrenlist={wanrenlist}></Wanren> : null}

                {seckilllist.length > 0 ? <Seckill seckilllist={seckilllist}></Seckill> : null}
            </div>
        )
    }
}
const mapStateToProps = (state) => {
    return {
        getnewlist:getNewlist(state),
        wanrenlist:getWanrenlist(state),
        seckilllist:getseckilllist(state)
    }
}
const mapDispatchToProps = (dispatch) => {
    return {
        home:bindActionCreators(actions,dispatch)
    }
}
export default connect(mapStateToProps, mapDispatchToProps)(home)
